package com.acwing.partition35;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/3/13 16:54
 */
public class AC3420括号序列 {

    private static final int N = 5010, MOD = (int) (1e9 + 7);
    private static char[] seq;
    //f[i][j]表示只考虑前i个括号，左括号比右括号多j个的所有方案的集合数量
    private static long[][] f = new long[N][N];
    private static int n;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        seq = reader.readLine().toCharArray();
        n = seq.length;
        long left = resolve();
        reverse();
        for (int i = 0; i < n; i++) {
            if (seq[i] == '(') seq[i] = ')';
            else seq[i] = '(';
        }
        long right = resolve();
        writer.write((left * right % MOD) + "\n");
        writer.flush();
    }

    private static long resolve() {
        for (int i = 0; i < f.length; i++) Arrays.fill(f[i], 0);
        f[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            if (seq[i - 1] == '(') {
                for (int j = 1; j <= n; j++) {
                    f[i][j] = f[i - 1][j - 1];
                }
            } else {
                f[i][0] = (f[i - 1][0] + f[i - 1][1]) % MOD;
                for (int j = 1; j <= n; j++) {
                    f[i][j] = (f[i - 1][j + 1] + f[i][j - 1]) % MOD;
                }
            }
        }
        for (int i = 0; i <= n; i++) {
            if (f[n][i] != 0) return f[n][i];
        }
        return -1;
    }

    private static void reverse() {
        int l = 0, r = n - 1;
        while (l < r) {
            char t = seq[l];
            seq[l] = seq[r];
            seq[r] = t;
            l++;
            r--;
        }
    }
}
